<?php
/**
 * Create By: PhpStorm
 * User: yuanxuncheng
 * File: GetFlashSale.php
 * Date: 2017/1/2
 * Time: 23:13
 */

namespace app\api\model\page\common;

use app\api\model\dao\ComicfansExperience;
use app\library\Error;
use app\library\PageBase;
use think\Validate;
use think\Cache;

class GetComicfansExperience extends PageBase
{

    private $objComicfansExperience;

    public function __construct()
    {
        parent::__construct();
        $this->objComicfansExperience = new ComicfansExperience();
    }

    public function excute($param)
    {
        $perpage = isset($param['perpage']) ? intval($param['perpage']) : 0;
        $page = isset($param['page']) ? intval($param['page']) : 0;
        $perpage = max(20, $perpage);
        $page = max(1, $page);
        $offset = ($page - 1) * $perpage;
        $limit = $perpage;

        $arrField = array();
        $arrCond = array();
        $counts = $this->objComicfansExperience->getCount($arrCond);
        $ret = $this->objComicfansExperience->getComicfansExperienceByCond($arrCond, $arrField, $offset, $limit, ' add_time desc ');

        $this->data = array(
            'list' => $ret,
            'total' => $counts,
        );

        return $this->getRes();
    }
}
